loadstring(exports.dgs:dgsImportFunction())()

local sw,sh = guiGetScreenSize()
local px,py = sw/1366,sh/768
font = dgsCreateFont( ":cmta-pobieraniezasobow/OSB.ttf", 15*px )
font2 = dgsCreateFont( ":cmta-pobieraniezasobow/OSB.ttf", 11*px )

cmtaSCOREBOARD = false

function stworztaba()
    rndRect = dgsCreateRoundRect(0,false,tocolor(30,30,30,210))  
    rect = dgsCreateImage(350*px,150*py,666*px,468*py,rndRect,false)
    gridlist = dgsCreateGridList (0*px, 80*py, 666*px, 388*py, false,rect )
    dgsGridListAddColumn( gridlist, "ID", 0.1 ) 
    dgsGridListAddColumn( gridlist, "UID", 0.1 ) 
    dgsGridListAddColumn( gridlist, "Poziom", 0.1 )
    dgsGridListAddColumn( gridlist, "Nick", 0.3 ) 
    dgsGridListAddColumn( gridlist, "Gang", 0.25 ) 
    dgsGridListAddColumn( gridlist, "Ping", 0.1 ) 
    local time = getRealTime()
    if time.minute >= 60 then time.minute  = time.minute-60; time.hour=time.hour+1 end
	local czas = string.format("%02d:%02d",time.hour, time.minute)
    text1 = dgsCreateLabel(10*px,30*py,646*px,50*py,"Godzina: "..czas.."\nAktualna sesja: "..(getElementData(localPlayer,"player:data").currentplaytime).." min",false,rect)
    dgsSetFont( text1, font2 )
    dgsSetProperty(text1,"colorcoded",true)
    dgsSetProperty(text1,"alignment",{"left","center"})
    text2 = dgsCreateLabel(10*px,10*py,646*px,70*py,"#ff0000ClickerMTA #ffffff- #808080wyklikaj swoją przyszłość",false,rect)
    dgsSetFont( text2, font )
    dgsSetProperty(text2,"colorcoded",true)
    dgsSetProperty(text2,"alignment",{"left","top"})
    text = dgsCreateLabel(0*px,0*py,646*px,80*py,"#ccc000"..#getElementsByType("player").." / 19",false,rect)
    dgsSetFont( text, font )
    dgsSetProperty(text,"colorcoded",true)
    dgsSetProperty(text,"alignment",{"right","center"})
    for i,v in pairs(getElementsByType("player")) do
        if getElementData(v,"player:data") and getElementData(v,"player:data").vip then dane = "[V.I.P] " else dane = "[Gracz] " end
        if getElementData(v,"player:data") then
            local row = dgsGridListAddRow ( gridlist )
            dgsGridListSetItemText ( gridlist, row, 1, getElementData(v,"id") )
            dgsGridListSetItemText ( gridlist, row, 2, getElementData(v,"player:data").uid )
            dgsGridListSetItemText ( gridlist, row, 3, getElementData(v,"player:data").lvl )
            dgsGridListSetItemText ( gridlist, row, 4, ""..dane..""..getPlayerName(v):gsub("#%x%x%x%x%x%x","").."" )
            dgsGridListSetItemText ( gridlist, row, 5, (getElementData(v,"player:data").gang or ""))
            dgsGridListSetItemText ( gridlist, row, 6, getPlayerPing(v))
            if getElementData(v,"player:data").vip then
            dgsGridListSetItemColor (gridlist, row, 4 , 217, 115, 25)
            end
            local number = i%2
            if number == 0 then
            dgsGridListSetRowBackGroundColor(gridlist,row,tocolor(80,80,80,155),tocolor(80,80,80,155),tocolor(255,80,80,155))
            else
            dgsGridListSetRowBackGroundColor(gridlist,row,tocolor(80,80,80,195),tocolor(80,80,80,195),tocolor(255,80,80,155))
            end
        else
        local row = dgsGridListAddRow ( gridlist )
        dgsGridListSetItemText ( gridlist, row, 1, "" )
        dgsGridListSetItemText ( gridlist, row, 2, "" )
        dgsGridListSetItemText ( gridlist, row, 3, "" )
        dgsGridListSetItemText ( gridlist, row, 4, "-- Niezalogowany --" )
        dgsGridListSetItemText ( gridlist, row, 5, "" )
        dgsGridListSetItemText ( gridlist, row, 6, getPlayerPing(v))
        
        end
    end
    cmtaSCOREBOARD = true
    showCursor(true)
end

function wlacztaba()
    if getElementData(localPlayer,"player:data").uid then
        stworztaba()
    end
end

function wylacztaba()
if cmtaSCOREBOARD then
    cmtaSCOREBOARD = false
    destroyElement(rndRect)
    destroyElement(rect)
    showCursor(false)

end
end

bindKey("tab", "down", wlacztaba)
bindKey("tab", "up", wylacztaba)